from django.conf.urls import url
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from apps.meiduo_admin.views import goods_brands
from apps.meiduo_admin.views import goods_channels
from apps.meiduo_admin.views import orders
from apps.meiduo_admin.views import permission
from apps.meiduo_admin.views import skus_images
from apps.meiduo_admin.views import specs
from apps.meiduo_admin.views import specs_options
from apps.meiduo_admin.views import spus
from apps.meiduo_admin.views import statistical
from apps.meiduo_admin.views import users
from apps.meiduo_admin.views import skus

urlpatterns = [
    # #访问jwt token数据
    url(r'^authorizations/$', obtain_jwt_token),

    # url(r'^authorizations/$',  permission.LoginView.as_view()),
    # 用户总数分析路由
    url(r'^statistical/total_count/$', statistical.TotalCountView.as_view()),
    # 日增用户统计
    url(r'^statistical/day_increment/$', statistical.DayIncrementView.as_view()),
    # 日活用户统计
    url(r'^statistical/day_active/$', statistical.DayActiveView.as_view()),
    # 日下单用户统计
    url(r'^statistical/day_orders/$', statistical.DayOrdersView.as_view()),
    # 月增用户统计
    url(r'^statistical/month_increment/$', statistical.MonthIncrementView.as_view()),
    # 日分类商品访问量
    url(r'^statistical/goods_day_views/$', statistical.GoodsDayViews.as_view()),
    # 用户查询的获取
    url(r'^users/$', users.UsersView.as_view()),
    # 保存规格表数据表数据
    # url(r'^goods/simple/$', specs.SPUSimpleView.as_view({'get': 'list'})),
    # 获取商品的三级分类
    url(r'^skus/categories/$', skus.SKUCategorieView.as_view()),
    # 获取spu信息
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SPUSpecView.as_view()),
    # 获取权限数据
    url(r'^permission/perms/$', permission.PermissionView.as_view()),
    # 保存用户组
    url(r'^permission/simple/$', permission.GroupsView.as_view({'get': 'simple'})),
    # # 获取分组数据
    # url(r'^permission/groups/simple/$', permission.AdminView.as_view({'get': 'simple'})),
    # 获取分组数据
    url(r'^permission/groups/simple/$', permission.GroupSimpleView.as_view()),
    # 获取品牌信息
    url(r'^goods/brands/simple/$', spus.GoodsBrandsView.as_view()),
    # 获取品牌信息
    url(r'^goods/specs/simple/$', spus.GoodsBrandsView.as_view()),
    # 获取一级分类
    url(r'^goods/channel/categories/$', spus.GoodsCategoriesOneView.as_view()),
    # 获取商品的二三级分类
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', spus.GoodsCategoriesTwoThreeView.as_view()),
    # 上传照片
    url(r'^goods/images/$', spus.GoodsImageiew.as_view()),
    # 获取所有的sku
    url(r'^skus/simple/$', skus_images.SkuSimpleView.as_view()),
    # 获取商品的一级分类(频道组管理时)
    url(r'^goods/categories/$', spus.GoodsCategoriesOneView.as_view()),
    # 获取所有的组名
    url(r'^goods/channel_types/$', goods_channels.GoodsChannelTypes.as_view()),

    # url(r'^goods/specs/$', specs.SpecsView.as_view()),

    # url(r'^goods/<?P<pk>\d+/specs/$', specs.SpecView.as_view()),

]
# 规格表列表数据操作
router = DefaultRouter()
# 频道管理
router.register('goods/channels', goods_channels.GoodsChannels, base_name="goods_channels")
# 品牌管理
router.register('goods/brands', goods_brands.GoodsBrands, base_name="brands")
# 为规格分类生成路由
router.register("goods/specs", specs.SpecsViewSet, base_name="specs")
router.register("goods/simple", specs.SPUSimpleView, base_name="simple")
# 图片表管理
router.register('skus/images', skus_images.SkusImagesView, base_name="images")
# 商品分类
router.register("skus", skus.SKUGoodsView, base_name="skus")
# 获取订单表数据
router.register("orders", orders.OrdersView, base_name="orders")
# 用户组管理
router.register('permission/groups', permission.GroupsView, base_name="groups")
# 管理员管理
router.register('permission/admins', permission.AdminView, base_name="admins")
# spu表管理
router.register('goods', spus.SpusView, base_name="goods")
# 规格表管理
router.register('specs/options', specs_options.SpecsOptions, base_name="specs_options")

urlpatterns += router.urls
